﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SilkeyERP.BL.Controller
{
    public class CustomerController  : NAGFwk.BL.IBaseController<Model.Customer>
    {
        private SilkeyERP.Model.Repository.ICustomerRepository Repository;

        public CustomerController ()
        {
            this.Repository = new Model.Repository.CustomerRepository();
        }

        public CustomerController(SilkeyERP.Model.Repository.CustomerRepository _Repository)
        {            
            this.Repository = _Repository;
        }

        public IEnumerable<Model.Customer> GetAll()
        {
            return Repository.GetAll().Where(x => x.Enable == true).ToList();
        }

        public void Insert(Model.Customer Obj)
        {
            Obj.Enable = true;
            Repository.Insert(Obj);
        }

        public void Delete(int ID)
        {
            Repository.Delete(ID);
        }

        public void DeleteLogical(int ID)
        {
            Repository.DeleteLogical(ID);
        }

        public void Update(Model.Customer Obj)
        {
            Repository.Update(Obj);
        }

        public void Dispose()
        {
            Repository.Dispose();
        }

        public Model.Customer GetByID(int ID)
        {
            return Repository.GetByID(ID);
        }




        public void Delete(Model.Customer Obj)
        {
            Delete(Obj.CustomerID);
        }

        public void DeleteLogical(Model.Customer Obj)
        {
            DeleteLogical(Obj.CustomerID);
        }
    }
}
